package tech.dort.dortware.impl.modules.exploit;

import com.google.common.eventbus.Subscribe;
import net.minecraft.network.play.client.C03PacketPlayer;
import net.minecraft.network.play.server.S00PacketKeepAlive;
import tech.dort.dortware.api.module.Module;
import tech.dort.dortware.api.module.ModuleData;
import tech.dort.dortware.impl.events.PacketEvent;

public class PotionSaver extends Module {
    public PotionSaver(ModuleData moduleData) {
        super(moduleData);
    }

    @Subscribe
    public void onPacket(PacketEvent event) {
        if (mc.thePlayer == null || !mc.thePlayer.getActivePotionEffects().isEmpty())
            return;
        switch (event.getPacketDirection()) {
            case OUTBOUND:
                event.forceCancel(event.getPacket() instanceof C03PacketPlayer && !mc.thePlayer.isMoving());
                break;
            case INBOUND:
                event.forceCancel(event.getPacket() instanceof S00PacketKeepAlive && !mc.thePlayer.isMoving());
                break;
        }
    }
}
